package com.ght.springboot.schedule;

import org.quartz.Trigger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import javax.sql.DataSource;

/**
 * @description:
 * @author: haitao.gao
 * @create: 2019-03-13 07:21
 **/
@Configuration
public class QuartzConfig {

//    @Autowired
//    @Qualifier(value = "dataSource")
//    private DataSource dataSource;
//
//    /**
//     * 调度器工厂Bean
//     */
//    @Bean(name = "schedulerFactory")
//    public SchedulerFactoryBean schedulerFactory(@Qualifier("myFirstExerciseJobTrigger") Trigger myFirstExerciseJobTrigger) {
//        SchedulerFactoryBean bean = new SchedulerFactoryBean();
//        // 覆盖已存在的任务
//        bean.setOverwriteExistingJobs(true);
//        // 延时启动定时任务，避免系统未完全启动却开始执行定时任务的情况
//        bean.setStartupDelay(15);
//        bean.setDataSource(dataSource);
//        // 注册触发器
//        bean.setTriggers(myFirstExerciseJobTrigger);
//        return bean;
//    }

}
